package cn.tedu.thread;

/*本类测试多线程编程方式二*/
public class TestThread2 {
    public static void main(String[] args) {
        new Thread(new MyRunnable("你爷爷")).start();
        new Thread(new MyRunnable("你爸爸")).start();
        new Thread(new MyRunnable("你自己")).start();
    }
}

class MyRunnable implements Runnable {
    private String name;

    public MyRunnable(String name) {
        this.name = name;

    }

    @Override
    public void run() {
        Thread.currentThread().setName(name);
        for (int i = 0; i < 10; i++) {

            System.out.println(i + Thread.currentThread().getName());
        }
    }
}